import requests
from PIL import Image
import pytesseract
#
# '''
# 简单验证码
# '''
# # 验证码地址
# # url = "http://rap2.local:32601/captcha?t=1648864612287"
# # response = requests.get(url).content
#
# # 将图片写入文件
# # with open('H:\\tmp\\yzm', 'wb') as f:
# #   f.write(response)
# #   f.close()
#
# '''识别验证码'''
# # 第一步：通过内置模块PIL打开文件
# pic = Image.open('H:\\tmp\\1.png')
# # 第二步：识别图片中的内容
# pic_str = pytesseract.image_to_string(pic)
# print("验证码识别结果为:", pic_str)
#
#
# s1 = 72
# s2 = 85
# r = (s2/s1 - 1) * 100
# print('%.1f%%' % r)
#
# n1 = 255
# n2 = 1000
# print(hex(n1))

# import math
# def quadratic(a, b, c):
#     return (-b + math.sqrt(b*b - 4*a*c)) / (2*a)
#
# print('quadratic(2, 3, 1) =', quadratic(2, 3, 1))
# print('quadratic(1, 3, -4) =', quadratic(1, 3, -4))
#
# if quadratic(2, 3, 1) != -0.5:
#     print('测试失败')
# elif quadratic(1, 3, -4) != 1.0:
#     print('测试失败')
# else:
#     print('测试成功')

#
# def person(name, age, **kw):
#     print('name:', name, 'age:', age, 'other:', kw)
#
# person('Bob', 35, city='Beijing')
# person('Adam', 45, gender='M', job='Engineer')
#
# extra = {'city': 'Beijing', 'job': 'Engineer'}
# person('Jack', 24, **extra)
#
# def person2(*v, **kw):
#     print('v:', v, 'other:', kw)
#
# person2('Bob', 35, city='Beijing')
# person2('Adam', 45, gender='M', job='Engineer')

#
#
# def f1(a, b, c=0, *args, **kw):
#     print('a =', a, 'b =', b, 'c =', c, 'args =', args, 'kw =', kw)
#
# def f2(a, b, c=0, *, d, **kw):
#     print('a =', a, 'b =', b, 'c =', c, 'd =', d, 'kw =', kw)
#
# args = (1, 2, 3, 4)
# kw = {'d': 99, 'x': '#'}
# f1(*args, **kw)
#
#

#
# def mul(*args):
#     if len(args) == 0:
#         raise Exception
#     l = list(args)
#     r = l.pop()
#     for item in l:
#         r = r * item
#     return r
#
# # print('mul() =', mul())
# print('mul(5) =', mul(5))
# print('mul(5, 6) =', mul(5, 6))
# print('mul(5, 6, 7) =', mul(5, 6, 7))
# print('mul(5, 6, 7, 9) =', mul(5, 6, 7, 9))
#
# if mul(5) != 5:
#     print('测试失败!')
# elif mul(5, 6) != 30:
#     print('测试失败!')
# elif mul(5, 6, 7) != 210:
#     print('测试失败!')
# elif mul(5, 6, 7, 9) != 1890:
#     print('测试失败!')
# else:
#     try:
#         mul()
#         print('测试失败!')
#     except Exception:
#         print('测试成功!')


# d = {'x': 'A', 'y': 'B', 'z': 'C' }
#
# print(d.items())
#
# L1 = ['Hello', 'World', 18, 'Apple', None]
#
# L2 = [ x.lower() for x in L1 if isinstance(x, str) ]
# print(L2)

# def odd():
#     print('step 1')
#     yield 1
#     print('step 2')
#     yield(3)
#     print('step 3')
#     yield(5)
#
# for i in odd():
#     print('-------', + i)


# for i in range(2):
#     print(i)

#
# def triangles():
#     lastArr = [1, 1]
#     yield [1]
#     yield lastArr
#     while True:
#         tmpArr = []
#         for i in range(1, len(lastArr)):
#             tmpValue = lastArr[i-1] + lastArr[i]
#             tmpArr.append(tmpValue)
#         tmpArr.append(1)
#         tmpArr.insert(0, 1)
#         yield tmpArr
#         lastArr = tmpArr
#
# n = 0
# results = []
# for t in triangles():
#     results.append(t)
#     n = n + 1
#     if n == 10:
#         break
#
# for t in results:
#     print(t)
#
# if results == [
#     [1],
#     [1, 1],
#     [1, 2, 1],
#     [1, 3, 3, 1],
#     [1, 4, 6, 4, 1],
#     [1, 5, 10, 10, 5, 1],
#     [1, 6, 15, 20, 15, 6, 1],
#     [1, 7, 21, 35, 35, 21, 7, 1],
#     [1, 8, 28, 56, 70, 56, 28, 8, 1],
#     [1, 9, 36, 84, 126, 126, 84, 36, 9, 1]
# ]:
#     print('测试通过!')
# else:
#     print('测试失败!')

# from functools import reduce
#
# def fn(x, y):
#     return x * 10 + y
#
# def char2num(s):
#     digits = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}
#     return digits[s]
# print(reduce(fn, map(char2num, '13579')))
#
#
# from functools import reduce

#
# def a(*args_a):
#     def b(*args_b):
#         print(args_a)
#         print(args_b)
#     return b
#
# bFn = a(1, 2)
# bFn(3,4)

#
# def log(func):
#     def wrapper(*args, **kw):
#         print('call %s():' % func.__name__)
#         return func(*args, **kw)
#     return wrapper
# @log
# def now():
#     print('2015-3-25')
#     return 'now fun result'
#
# print(now())
#

# def log(text):
#     def decorator(func):
#         def wrapper(*args, **kw):
#             print('%s %s():' % (text, func.__name__))
#             return func(*args, **kw)
#         return wrapper
#     return decorator
#
# @log('execute')
# def now():
#     print('2015-3-25')
#
# now()

#
# class Student(object):
#     count = 0
#     def __init__(self, name):
#         Student.count += 1
#         self.name = name
#
# if Student.count != 0:
#     print('测试失败!')
# else:
#     bart = Student('Bart')
#     if Student.count != 1:
#         print('测试失败 11!')
#     else:
#         lisa = Student('Bart')
#         if Student.count != 2:
#             print('测试失败 12!')
#         else:
#             print('Students:', Student.count)
#             print('测试通过!')
#
#
#
# class Screen(object):
#     def __init__(self, width, height):
#         self._width = width
#         self._height = height
#
#     @property
#     def width(self):
#         return self._width
#
#     @width.setter
#     def width(self, width):
#         self._width = width
#
#     @property
#     def height(self):
#         return self._height
#
#     @height.setter
#     def height(self, height):
#         self._height = height
#
#     @property
#     def resolution(self):
#         return self._height * self._width
#
# # 测试:
# s = Screen(1024, 768)
# s.width = 1024
# s.height = 768
# print('resolution =', s.resolution)
# if s.resolution == 786432:
#     print('测试通过!')
# else:
#     print('测试失败!')



# class Chain(object):
#
#     def __init__(self, path=''):
#         self._path = path
#
#     def __getattr__(self, path):
#         return Chain('%s/%s' % (self._path, path))
#
#     def __str__(self):
#         return self._path
#
#     __repr__ = __str__
#
# print(Chain().status.user.timeline.list)

# from enum import Enum
#
# Month = Enum('Month', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'))
#
# for name, member in Month.__members__.items():
#     print(name, '=>', member, ',', member.value)
#


#
# # metaclass是类的模板，所以必须从`type`类型派生：
# class ListMetaclass(type):
#     def __new__(cls, name, bases, attrs):
#         print('cls:', cls)   # <class '__main__.ListMetaclass'> 返回当前元类ListMetaclass的类对象<class '__main__.ListMetaclass'>
#         print('name:', name)   # MyList 返回 最开始的MyList类的名称
#         print('bases:', bases)  # (<class 'list'>,)
#         print('attrs:', attrs)  # {'__module__': '__main__', '__qualname__': 'MyList'}
#         attrs['add'] = lambda self, value: self.append(value)
#         return type.__new__(cls, name, bases, attrs)
#
# # 有了ListMetaclass，我们在定义类的时候还要指示使用ListMetaclass来定制类，传入关键字参数metaclass
#
# class MyList(list, metaclass=ListMetaclass):
#     pass
# # 当我们传入关键字参数metaclass时，魔术就生效了，它指示Python解释器在创建MyList时，要通过ListMetaclass.__new__()来创建，在此，我们可以修改类的定义，比如，加上新的方法，然后，返回修改后的定义
# # __new__()方法接收到的参数依次是：
# # 1. 当前准备创建的类的对象
# # 2. 类的名字
# # 3. 类继承的父类集合
# # 4. 类的方法集合
#



#
#
# class Field(object):
#
#     def __init__(self, name, column_type):
#         self.name = name
#         self.column_type = column_type
#
#     def __str__(self):
#         return '<%s:%s>' % (self.__class__.__name__, self.name)
#
#
# class StringField(Field):
#
#     def __init__(self, name):
#         super(StringField, self).__init__(name, 'varchar(100)')
#
#
# class IntegerField(Field):
#
#     def __init__(self, name):
#         super(IntegerField, self).__init__(name, 'bigint')
#
#
# class ModelMetaclass(type):
#     def __new__(cls, name, bases, attrs):
#         if name=='Model':
#             return type.__new__(cls, name, bases, attrs)
#         print('Found model: %s' % name)
#         mappings = dict()
#         for k, v in attrs.items():
#             if isinstance(v, Field):
#                 print('Found mapping: %s ==> %s' % (k, v))
#                 mappings[k] = v
#         for k in mappings.keys():
#             attrs.pop(k)
#         attrs['__mappings__'] = mappings # 保存属性和列的映射关系
#         attrs['__table__'] = name # 假设表名和类名一致
#         return type.__new__(cls, name, bases, attrs)
#
#
# class Model(dict, metaclass=ModelMetaclass):
#
#     def __init__(self, **kw):
#         super(Model, self).__init__(**kw)
#
#     def __getattr__(self, key):
#         try:
#             return self[key]
#         except KeyError:
#             raise AttributeError(r"'Model' object has no attribute '%s'" % key)
#
#     def __setattr__(self, key, value):
#         self[key] = value
#
#     def save(self):
#         fields = []
#         params = []
#         args = []
#         for k, v in self.__mappings__.items():
#             fields.append(v.name)
#             params.append('?')
#             args.append(getattr(self, k, None))
#         sql = 'insert into %s (%s) values (%s)' % (self.__table__, ','.join(fields), ','.join(params))
#         print('SQL: %s' % sql)
#         print('ARGS: %s' % str(args))
#
#
# class User(Model): # 定义 User类的时候，会通过ModelMetaclass创建元类，返回创建的元类，然后将这个元类作为User的基类
#     # 定义类的属性到列的映射：
#     id = IntegerField('id')
#     name = StringField('username')
#     email = StringField('email')
#     password = StringField('password')


#
# from concurrent.futures import ThreadPoolExecutor
# import time
#
# def spider(page):
#     time.sleep(page)
#     print(f"crawl task{page} finished")
#     return page
#
# with ThreadPoolExecutor(max_workers=5) as t:  # 创建一个最大容纳数量为5的线程池
#     task1 = t.submit(spider, 1)
#     task2 = t.submit(spider, 2)  # 通过submit提交执行的函数到线程池中
#     task3 = t.submit(spider, 3)
#
#     print(f"task1: {task1.done()}")  # 通过done来判断线程是否完成 返回True False
#     print(f"task2: {task2.done()}")
#     print(f"task3: {task3.done()}")
#
#     time.sleep(8)
#     print(f"task1: {task1.done()}")
#     print(f"task2: {task2.done()}")
#     print(f"task3: {task3.done()}")
#     print(task1.result())  # 通过result来获取返回值
#

#
# #coding=utf-8
# import threading
# from time import ctime, sleep
#
#
# def music(func):
#     for i in range(2):
#         sleep(2)
#         print("I was listening to %s. %s" % (func, ctime()))
#
#
# def move(func):
#     for i in range(2):
#         sleep(10)
#         print("I was at the %s! %s" % (func, ctime()))
#
#
# threads = []
# t1 = threading.Thread(target=music, args=(u'爱情买卖',))
# threads.append(t1)
# t2 = threading.Thread(target=move, args=(u'阿凡达',))
# threads.append(t2)
#
# if __name__ == '__main__':
#     for t in threads:
#         # t.setDaemon(True) # 将线程声明为守护线程
#         t.start()
#         print()
#     #print("all over %s" %ctime())

#
# with open('test.txt', 'a') as f:
#     f.write('def')
#     f.write('\n')

# import json

# data = [ { 'a' : 1, 'b' : 2, 'c' : 3, 'd' : 4, 'e' : 5 } ]
# data2 = json.dumps({'a': 'Runoob', 'b': 7}, sort_keys=True, indent=4, separators=(',', ': '))
# print(data2) # json格式的字符串

# strJsonData = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
# text = json.loads(strJsonData)
# print(text)


# import threading
# import time
# from concurrent.futures import Future
# from concurrent.futures.thread import ThreadPoolExecutor
# from concurrent.futures.process import ProcessPoolExecutor
#
# local = threading.local()
# def logIt(value):
#     print('log', value, local.taskId)
#
# def func(value, i):
#     local.taskId = i
#     print('print value and i', value, i)
#     time.sleep(1)
#     logIt(value)
#     return value
#
# pool = ThreadPoolExecutor(max_workers=3)
# #pool = ProcessPoolExecutor(max_workers=3)
#
# if __name__ == '__main__':
#     for i in range(10):
#         fut = pool.submit(func, i, i)
import time


if __name__ == '__main__':
    time.sleep(0.5)
    print('0.5')



